#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
最终验证所有预制件文件的Unicode编码情况
"""

import re
from pathlib import Path

def check_all_prefabs():
    """检查所有预制件文件"""
    prefab_dir = Path("Assets/Prefabs")
    prefab_files = list(prefab_dir.glob("*.prefab"))
    
    print("=== 最终验证报告 ===")
    print(f"检查目录: {prefab_dir}")
    print(f"预制件文件数: {len(prefab_files)}")
    print()
    
    total_unicode = 0
    problem_files = []
    
    for prefab_file in sorted(prefab_files):
        with open(prefab_file, 'r', encoding='utf-8') as f:
            content = f.read()
        
        unicode_patterns = re.findall(r'm_Name: "([^"]*\\u[0-9a-fA-F]{4}[^"]*)"', content)
        unicode_count = len(unicode_patterns)
        total_unicode += unicode_count
        
        status = "✓" if unicode_count == 0 else "⚠️"
        print(f"{status} {prefab_file.name}: {unicode_count} 个Unicode编码")
        
        if unicode_count > 0:
            problem_files.append(prefab_file.name)
            for i, pattern in enumerate(unicode_patterns[:3]):  # 只显示前3个
                print(f"    {i+1}. {pattern}")
            if len(unicode_patterns) > 3:
                print(f"    ... 还有 {len(unicode_patterns)-3} 个")
    
    print()
    print("=== 总结 ===")
    if total_unicode == 0:
        print("🎉 所有预制件文件都已完全处理完成！")
        print("✅ 没有发现任何Unicode编码的中文节点")
    else:
        print(f"⚠️  仍有 {total_unicode} 个Unicode编码的中文节点")
        print(f"问题文件: {', '.join(problem_files)}")
    
    return total_unicode == 0

if __name__ == "__main__":
    check_all_prefabs() 